<?php
namespace app\admin\controller;
use think\Controller;
use think\Db;
use think\Request;
class Index extends Controller
{
	
    public function index()
    {
		return $this->fetch();
    }
    /*
	登录页面
	*/
    public function login()
    {
		return $this->fetch();
    }
	/*
	管理活动分类页面
	*/
	public function mantype()
	{
		return $this->fetch('mtype');
	}
	/*
	添加活动分类
	*/
	public function itype()
	{
		
	}
	/*
	活动管理页面
	*/
	public function manact()
	{
		return $this->fetch();
	}
	/*
	活动详情
	*/
	public function actionlog(){
		return $this->fetch();
	}
	/*
	学生信息
	*/
	public function student(){
		return $this->fetch();
	}
	/*
	编辑修改
	*/
	public function edit(){
        $id = Request::instance()->get('id');
        $flag = Request::instance()->get('flag');

        $data = Db::table('fieldsinfo')->where('tablename',$flag)->find();
        // print_r($data);
        $data1 = Db::table($flag)->where('id',$id)->find();
        $fields = json_decode($data['fieldsname'],true);
        // print_r($fields);
        foreach ($fields as $key => $value) {
        	$fields[$key]['value'] = $data1[$value['fields']];
        }
        $this->assign('flag',$flag);
        $this->assign('fields',$fields);
        return $this->fetch();
    }
    /*
	添加操作
    */
    public function add(){
    	$id = Request::instance()->get('id');
    	$flag = Request::instance()->get('flag');

    	$data = Db::table('fieldsinfo')->where('tablename',$flag)->find();
    	$fields = json_decode($data['fieldsname'],true);
    	// print_r($data);	
    	// print_r($fields);
    	$this->assign('flag',$flag);
    	$this->assign('fields',$fields);
    	return $this->fetch();
    }
}
